package com.onnext.androidsdk

import android.os.Bundle
import android.support.v4.app.Fragment
import com.onnext.androidsdk.base.BaseActivity
import com.onnext.androidsdk.config.Names

class ModuleActivity : BaseActivity() {

    private lateinit var extras:Bundle
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_module)
        init()
    }

    fun init() {
        extras = intent.extras
        var className = extras.getString(Names.ClassName)
        var title = extras.getString(Names.Title)
        var newInstance = Class.forName(className).getMethod("newInstance",Bundle::class.java)
        var fragment = newInstance.invoke(null,extras) as Fragment
        supportFragmentManager.beginTransaction().replace(R.id.container,fragment).commitAllowingStateLoss()
        setTitle(title)
        showBack()
    }
}
